package com.ssc.shalomsoft;

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;

public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {

	public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
		super(configurer);
	}

	public ActionBarAdvisor createActionBarAdvisor(
			IActionBarConfigurer configurer) {
		return new ApplicationActionBarAdvisor(configurer);
	}

	public void preWindowOpen() {
		IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
		configurer.setInitialSize(new Point(400, 300));
		
		configurer.setShowCoolBar(true);
		configurer.setShowStatusLine(true);
	}
	public void postWindowCreate() {
	     super.postWindowCreate();
	     //get the workbench window
	     IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
	     Display display = configurer.getWindow().getWorkbench().getDisplay();
	     //get the desktop window
	     Monitor primaryMonitor = display.getPrimaryMonitor ();
	     Rectangle bounds = primaryMonitor.getBounds ();
	     Rectangle rect = configurer.getWindow().getShell().getBounds ();
	     int x = bounds.x + (bounds.width - rect.width) / 2 ;
	     int y = bounds.y + (bounds.height - rect.height) / 2 ;
	     int minWidth = 600;
	        int minHeight = 400;
	        configurer.getWindow().getShell().setBounds (x, y,minWidth, minHeight);
	        

	    }
}
